home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Misc Servers / Zope.exe / DTML-FUNCS.STX < prev    next >
Encoding:
Text File  |  2000-10-31  |  8.4 KB  |  180 lines

  1. functions: DTML Functions
  2.  
  3.   DTML utility functions provide some Python built-in functions and
  4.   some DTML-specific functions.
  5.  
  6.   Functions
  7.  
  8.     abs(number) -- Return the absolute value of a number. The argument may
  9.     be a plain or long integer or a floating point number. If the argument
  10.     is a complex number, its magnitude is returned.
  11.  
  12.     chr(integer) -- Return a string of one character whose ASCII code is
  13.     the integer i, e.g., chr(97) returns the string 'a'. This is the
  14.     inverse of ord(). The argument must be in the range [0..255],
  15.     inclusive; ValueError will be raised if i is outside that range.
  16.  
  17.     DateTime() -- Returns a Zope 'DateTime' object given constructor
  18.     arguments. See the "DateTime":DateTime.py API reference for more
  19.     information on constructor arguments.
  20.  
  21.     divmod(number, number) -- Take two numbers as arguments and return a
  22.     pair of numbers consisting of their quotient and remainder when using
  23.     long division. With mixed operand types, the rules for binary
  24.     arithmetic operators apply. For plain and long integers, the result
  25.     is the same as (a / b, a % b). For floating point numbers the result
  26.     is (q, a % b), where q is usually math.floor(a / b) but may be 1
  27.     less than that. In any case q * b + a % b is very close to a, if a %
  28.     b is non-zero it has the same sign as b, and 0 <= abs(a % b) <
  29.     abs(b).
  30.  
  31.     float(number) -- Convert a string or a number to floating point. If the
  32.     argument is a string, it must contain a possibly signed decimal or
  33.     floating point number, possibly embedded in whitespace; this
  34.     behaves identical to string.atof(x). Otherwise, the argument may be
  35.     a plain or long integer or a floating point number, and a floating
  36.     point number with the same value (within Python's floating point
  37.     precision) is returned.
  38.  
  39.     getattr(object, string) -- Return the value of the named attributed of
  40.     object. name must be a string. If the string is the name of one of the
  41.     object's attributes, the result is the value of that attribute. For
  42.     example, getattr(x, 'foobar') is equivalent to x.foobar. If the named
  43.     attribute does not exist, default is returned if provided, otherwise
  44.     AttributeError is raised.
  45.  
  46.     getitem(variable, render=0) -- Returns the value of a DTML variable.
  47.     If 'render' is true, the variable is rendered.
  48.  
  49.     hasattr(object, string) -- The arguments are an object and a
  50.     string. The result is 1 if the string is the name of one of the
  51.     object's attributes, 0 if not. (This is implemented by calling
  52.     getattr(object, name) and seeing whether it raises an exception or
  53.     not.)
  54.  
  55.     hash(object) -- Return the hash value of the object (if it has
  56.     one). Hash values are integers. They are used to quickly compare
  57.     dictionary keys during a dictionary lookup. Numeric values that compare
  58.     equal have the same hash value (even if they are of different types,
  59.     e.g. 1 and 1.0).
  60.  
  61.     has_key(variable) -- Returns true if the DTML namespace contains the
  62.     named variable.
  63.  
  64.     hex(integer) -- Convert an integer number (of any size) to a
  65.     hexadecimal string. The result is a valid Python expression. Note: this
  66.     always yields an unsigned literal, e.g. on a 32-bit machine, hex(-1)
  67.     yields '0xffffffff'. When evaluated on a machine with the same word
  68.     size, this literal is evaluated as -1; at a different word size, it
  69.     may turn up as a large positive number or raise an OverflowError
  70.     exception.
  71.  
  72.     int(number) -- Convert a string or number to a plain integer. If the
  73.     argument is a string, it must contain a possibly signed decimal number
  74.     representable as a Python integer, possibly embedded in whitespace;
  75.     this behaves identical to string.atoi(x[, radix]). The radix parameter
  76.     gives the base for the conversion and may be any integer in the range
  77.     [2, 36]. If radix is specified and x is not a string, TypeError is
  78.     raised. Otherwise, the argument may be a plain or long integer or a
  79.     floating point number. Conversion of floating point numbers to integers
  80.     is defined by the C semantics; normally the conversion truncates
  81.     towards zero.
  82.  
  83.     len(sequence) -- Return the length (the number of items) of an
  84.     object. The argument may be a sequence (string, tuple or list) or a
  85.     mapping (dictionary).
  86.  
  87.     max(s) -- With a single argument s, return the largest item of a
  88.     non-empty sequence (e.g., a string, tuple or list). With more than one
  89.     argument, return the largest of the arguments.
  90.  
  91.     min(s) -- With a single argument s, return the smallest item of
  92.     a non-empty sequence (e.g., a string, tuple or list). With more than
  93.     one argument, return the smallest of the arguments.
  94.  
  95.     namespace([name=value]...) -- Returns a new DTML namespace object.
  96.     Keyword argument 'name=value' pairs are pushed into the new
  97.     namespace.
  98.  
  99.     oct(integer) -- Convert an integer number (of any size) to an octal
  100.     string. The result is a valid Python expression. Note: this always
  101.     yields an unsigned literal, e.g. on a 32-bit machine, oct(-1) yields
  102.     '037777777777'. When evaluated on a machine with the same word size,
  103.     this literal is evaluated as -1; at a different word size, it may
  104.     turn up as a large positive number or raise an OverflowError
  105.     exception.
  106.  
  107.     ord(character) -- Return the ASCII value of a string of one
  108.     character. E.g., ord('a') returns the integer 97. This is the
  109.     inverse of chr().
  110.  
  111.     pow(x, y [,z]) -- Return x to the power y; if z is present, return
  112.     x to the power y, modulo z (computed more efficiently than pow(x, y) %
  113.     z). The arguments must have numeric types. With mixed operand types,
  114.     the rules for binary arithmetic operators apply. The effective operand
  115.     type is also the type of the result; if the result is not expressible
  116.     in this type, the function raises an exception; e.g., pow(2, -1) or
  117.     pow(2, 35000) is not allowed.
  118.  
  119.     range([start,] stop [,step]) -- This is a versatile function to
  120.       create lists containing arithmetic progressions.
  121.       The arguments must be plain integers. If the
  122.       step argument is omitted, it defaults to 1. If the start argument
  123.       is omitted, it defaults to 0. The full form returns a
  124.       list of plain integers [start, start + step, start + 2 * step,
  125.       ...]. If step is positive, the last element is the largest
  126.       start + i * step less than stop; if step is negative, the last
  127.       element is the largest start + i * step greater than stop. step
  128.       must not be zero (or else ValueError is raised).
  129.  
  130.     round(x [,n]) -- Return the floating point value x rounded to n
  131.     digits after the decimal point. If n is omitted, it defaults to
  132.     zero. The result is a floating point number. Values are rounded to the
  133.     closest multiple of 10 to the power minus n; if two multiples are
  134.     equally close, rounding is done away from 0 (so e.g. round(0.5) is 1.0
  135.     and round(-0.5) is -1.0).
  136.  
  137.     render(object) -- Render 'object'.  For DTML objects this renders
  138.     (calls) the DTML.  For other objects, this is equivalent to
  139.     'str(object)'.
  140.  
  141.     reorder(s [,with] [,without]) -- Reorder the items in s according
  142.       to the order given in with and with items mentioned in without
  143.       removed.  Items from s not mentioned in with are removed.  s,
  144.       with, and without are all either sequences of strings or
  145.       sequences of key-value tuples, with ordering done on the
  146.       keys. This function is useful for constructing ordered select
  147.       lists.
  148.  
  149.     str(object) -- Return a string containing a nicely printable
  150.     representation of an object. For strings, this returns the string
  151.     itself. 
  152.  
  153.     test(condition, result [,condition, result]... [,default]) --
  154.     Takes one or more condition, result pairs and returns the result
  155.     of the first true condition. Only one result is returned, even if
  156.     more than one condition is true. If no condition is true and a
  157.     default is given, the default is returned. If no condition is true
  158.     and there is no default, None is returned.
  159.  
  160.   Attributes
  161.  
  162.     None -- The 'None' object is equivalent to the Python built-in object
  163.     'None'.  This is usually used to represent a Null or false value.
  164.  
  165.   See Also
  166.  
  167.     "'string' module":dtml-string.stx
  168.  
  169.     "'whrandom' module":dtml-whrandom.stx
  170.  
  171.     "'math' module":dtml-math.stx
  172.  
  173.     "Built-in Python Functions":http://www.python.org/doc/current/lib/built-in-funcs.html
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.